home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Overload Trio 2
/
Shareware Overload Trio Volume 2 (Chestnut CD-ROM).ISO
/
dir42
/
fpw2xl.zip
/
PPGRP.PRG
< prev
Wrap
Text File
|
1993-06-25
|
9KB
|
312 lines
CLEAR
@ 10,10 SAY "PP Graph"
*
SET MESSAGE TO ""
*
CLOSE DATA
SELE 1
USE visit INDEX vid
*
SELE 2
USE C:\foxprow\apps\appt\graphs\lgtemp INDEX C:\foxprow\apps\appt\graphs\lgtemp EXCLUSIVE
SET SAFETY OFF
ZAP
SET SAFETY ON
SCATTER TO mtotal BLANK
mtotal(1)="TOTAL CASES"
SCATTER TO mpp BLANK
mpp(1)="Total Private Patients"
SCATTER TO mnhs BLANK
mnhs(1)="Total NHS Patients"
*
USE C:\foxprow\apps\appt\graphs\lgtemp INDEX C:\foxprow\apps\appt\graphs\lgtemp
SELE 3
USE providor INDEX iid
SELE 1
SET RELATION TO iid INTO providor
mrecs=RECCOUNT()
*
SCAN
IF MOD(RECNO(),10)=0
DO percent WITH mrecs,RECNO()
ENDIF
yi=YEAR(visit->appt_date)-1990
mi=MONTH(visit->appt_date)
ptr=yi*12 +mi +1
*
* ptr is used to update mtotal, mpp, mnhs as appropriate
*
mtotal(ptr) = mtotal(ptr) +1
DO CASE
CASE EMPTY(visit.ref_type)
IF (providor.name="unknown") .OR. ;
(providor.name="Mental Health") .OR. ;
("NHS" $ providor.name) .OR. ;
(providor.name="Northern Health and Soc") .OR. ;
(providor.name="Horton General Hospital") .OR. ;
(providor.name="Nuffield Orthopaedic Centre") .OR. ;
(providor.name="Salisbury Health Authority") .OR. ;
(providor.name="Eastern Health & Social Serv") .OR. ;
(providor.name="Western Health & Social Serv") .OR. ;
(providor.name="Western H & SS") .OR. ;
(providor.name="Southern H & SS") .OR. ;
(providor.name="SWINDON Health") .OR. ;
(providor.name="Wycombe Health") .OR. ;
(providor.name="Kettering General") .OR. ;
(providor.name="Worcester Royal Infirmary") .OR. ;
(providor.name="Northampton General") .OR. ;
(providor.name="Milton Keynes General") .OR. ;
(providor.name="Stantonbury Health Centre") .OR. ;
(providor.name="Gloucester Health") .OR. ;
(providor.name="Princess Alexandra Hosp") .OR. ;
(providor.name="South Warwickshire HA") .OR. ;
(providor.name="Basingstoke District Hospital") .OR. ;
(providor.name="Cambridge Military") .OR. ;
(providor.name="Bedford Hospital") .OR. ;
(providor.name="West Surrey & North East Hants") .OR. ;
(providor.name="Redbridge & Waltham Forest") .OR. ;
(providor.name="GP (Oxfordshire)") .OR. ;
(providor.name="RAF HALTON") .OR. ;
(providor.name="North West Anglia Health")
*
mnhs(ptr)=mnhs(ptr) +1
ELSE
mpp(ptr)=mpp(ptr) +1
ENDIF
CASE ref_type ="NHS"
mnhs(ptr)=mnhs(ptr) +1
CASE ref_type ="ECR"
mnhs(ptr)=mnhs(ptr) +1
CASE ref_type ="GPFH"
mnhs(ptr)=mnhs(ptr) +1
CASE ref_type ="PP"
mpp(ptr)=mpp(ptr) +1
ENDCASE
ENDSCAN
DO percent WITH 0
*
USE IN visit
USE IN providor
*
* Now fiddle with the results !
*
SELE lgtemp
APPE BLANK
GATHER FROM mtotal
APPE BLANK
GATHER FROM mpp
APPE BLANK
GATHER FROM mnhs
*
DELETE FILE s:\win\pp.csv
COPY TO s:\win\pp.csv DELIMITED
*
* Now the really fancy stuff...
*
xlsystem = -1
xlsheet1 = -1
*
=ddesetoption('SAFETY',.F.)
=ddesetoption('TIMEOUT',2000)
*
xlsystem = DDEINITIATE('Excel','System')
IF xlsystem <0
! /n2 C:\excel\excel
tries = 10
DO WHILE (tries >0) AND (xlsystem <0)
WAIT WINDOW "Waiting for"+CHR(13)+"EXCEL to initialise" TIMEOUT 2
tries = tries-1
xlsystem = DDEINITIATE('Excel','System')
ENDDO
IF tries =0
DO abend WITH "Excel not responding"
ENDIF
ENDIF
xlsheet1 = DDEINITIATE('Excel','Sheet1')
tries = 10
DO WHILE (tries >0) AND (xlsheet1 <0)
WAIT WINDOW "Waiting for"+CHR(13)+"EXCEL - Sheet1" TIMEOUT 2
tries = tries-1
xlsheet1 = DDEINITIATE('Excel','Sheet1')
ENDDO
IF tries =0
DO abend WITH "Sheet1 not responding"
ENDIF
*
* Now we have the DDE channels open
*
xlrow=1
FOR xlcol=2 TO 49
thedate=mmmyy(xlcol-1)
=rcpoke(thedate)
ENDFOR
*
xlrow=2
xlcol=1
=rcpoke('NHS')
FOR xlcol=2 TO 49
=rcpoke(ALLTRIM(STR(mnhs(xlcol))))
ENDFOR
*
xlrow=3
xlcol=1
=rcpoke('PP')
FOR xlcol=2 TO 49
=rcpoke(ALLTRIM(STR(mpp(xlcol))))
ENDFOR
*
* data complete, now graph it!
*
if not ddeexecute(xlsystem,'[select("R1:R3")]')
do abend with '[select(!R1:R3)]'
endif
if not ddeexecute(xlsystem,'[new(2)]')
do abend with "new(2)"
endif
if not ddeexecute(xlsystem,'[page.setup("","",1,1,1,1,3,TRUE,TRUE,2,9,200)]')
do abend with '[page.setup("","",1,1,1,1,3,TRUE,TRUE,2,9,200)]'
endif
*
if not ddeexecute(xlsystem,'[legend(TRUE)]')
do abend with '[legend(TRUE)]'
endif
if not ddeexecute(xlsystem,'[select("Legend")]')
do abend with '[select("Legend")]'
endif
if not ddeexecute(xlsystem,'[patterns(1,,,,FALSE,1,,,,FALSE)]')
do abend with '[patterns(1,,,,FALSE,1,,,,FALSE)]'
endif
if not ddeexecute(xlsystem,'[format.legend(3)]')
do abend with '[format.legend(3)]'
endif
*
if not ddeexecute(xlsystem,'[attach.text(1)]')
do abend with '[attach.text(1)]'
endif
if not ddeexecute(xlsystem,'[formula("=""Patient Referrals""")]')
do abend with '[formula("=""Patient Referrals""")]'
endif
if not ddeexecute(xlsystem,'[format.font(0,1,FALSE,"Arial",14,FALSE,FALSE,FALSE,FALSE)]')
do abend with '[format.font(0,1,FALSE,"Arial",14,FALSE,FALSE,FALSE,FALSE)]'
endif
*
if not ddeexecute(xlsystem,'[gallery.column(3,TRUE)]')
do abend with '[gallery.column(3,TRUE)]'
endif
if not ddeexecute(xlsystem,'[gridlines(FALSE,FALSE,TRUE,FALSE)]')
do abend with '[gridlines(FALSE,FALSE,TRUE,FALSE)]'
endif
*
if not ddeexecute(xlsystem,'[select("Axis 2")]')
do abend with '[select("Axis 2")]'
endif
if not ddeexecute(xlsystem,'[patterns(1,,,,4,1,4)]')
do abend with '[patterns(1,,,,4,1,4)]'
endif
if not ddeexecute(xlsystem,'[format.font(0,1,FALSE,"Arial",6,FALSE,FALSE,FALSE,FALSE)]')
do abend with '[format.font(0,1,FALSE,"Arial",6,FALSE,FALSE,FALSE,FALSE)]'
endif
*
* printing can take a while - allow 30 seconds!
*
=ddesetoption('TIMEOUT',30000)
if not ddeexecute(xlsystem,'[print(1,,,1,FALSE,FALSE,1)]')
do abend with '[print(1,,,1,FALSE,FALSE,1)]'
endif
*
* reset to 2 seconds
*
=ddesetoption('TIMEOUT',2000)
if not ddeexecute(xlsystem,'[gallery.column(5,TRUE)]')
do abend with '[gallery.column(5,TRUE)]'
endif
if not ddeexecute(xlsystem,'[gridlines(FALSE,FALSE,TRUE,FALSE)]')
do abend with '[gridlines(FALSE,FALSE,TRUE,FALSE)]'
endif
=ddesetoption('TIMEOUT',30000)
if not ddeexecute(xlsystem,'[print(1,,,1,FALSE,FALSE,1)]')
do abend with '[print(1,,,1,FALSE,FALSE,1)]'
endif
*
* reset to 2 seconds
*
=ddesetoption('TIMEOUT',2000)
if not ddeexecute(xlsystem,'[close(FALSE)]')
do abend with '[close(FALSE)] - Graph'
endif
*
* Close DDE conversation
*
IF NOT DDETERMINATE(xlsheet1)
DO abend WITH "Could not Terminate Sheet1"
ENDIF
xlsheet1 = -1
*
*
if not ddeexecute(xlsystem,'[close(FALSE)]')
do abend with '[close(FALSE)] - Sheet'
endif
*
* Close Excel
*
=ddeexecute(xlsystem,'[Quit]')
*
* We can ignore the error from this, because we shut down Excel with the
* previous command...
*
=DDETERMINATE(xlsystem)
xlsystem = -1
*
*
*
DO abend
RETURN
FUNCTION rc
PARAMETERS arow,acol
RETURN 'R'+ALLTRIM(STR(arow))+'C'+ALLTRIM(STR(acol))
FUNCTION mmmyy
PARAMETER monthindex
yi=0
mi=monthindex%12
yi=INT(monthindex/12)
yi=IIF(mi=0,yi-1,yi)
mi=IIF(mi=0,12,mi)
RETURN LEFT(CMONTH(CTOD('1/'+STR(mi)+'/90')),3)+'-'+ALLTRIM(STR(yi+90))
PROCEDURE rcpoke
PARAMETERS astring
IF NOT DDEPOKE(xlsheet1,rc(xlrow,xlcol),astring)
DO abend WITH "Poke @"+rc(xlrow,xlcol)+" "+astring
ENDIF
RETURN
PROCEDURE abend
PARAMETERS amessage
IF TYPE('amessage') = 'C'
WAIT WINDOW "DDE Error"+CHR(13)+amessage
ENDIF
CLOSE DATA
CLEAR
RELEASE mtotal
RELEASE mpp
RELEASE mnhs
IF TYPE('amessage') = 'C'
if xlsheet1 # -1
=DDETERMINATE(xlsheet1)
endif
if xlsystem # -1
=DDETERMINATE(xlsystem)
endif
CANCEL
ENDIF
RETURN